package com.bite.aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Aspect
public class AspectDemo {
    @Pointcut("execution(* com.bite.aop.controller.*.*(..))")
    private void pt(){

    }

    @Before("pt()")
    public void doBefore(){
        log.info("do before.....");
    }
/*    @Before("execution(* com.bite.aop.controller.*.*(..))")
    public void doBefore(){
        log.info("do before.....");
    }*/

/*    @After("execution(* com.bite.aop.controller.*.*(..))")
    public void doAfter(){
        log.info("do After.....");
    }

    @Around("execution(* com.bite.aop.controller.*.*(..))")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {   //必须要有返回结果
        log.info("do Around before.....");
        Object result = joinPoint.proceed();
        log.info("do Around after.....");
        return result;
    }

    @AfterReturning("execution(* com.bite.aop.controller.*.*(..))")
    public void doAfterReturning(){
        log.info("do AfterReturning.....");
    }

    @AfterThrowing("execution(* com.bite.aop.controller.*.*(..))")
    public void doAfterThrowing(){
        log.info("do AfterThrowing.....");
    }*/
}
